
/*
# ============================================================================
# 版权所有 Chilcoo.com，并保留所有权利。
# 网站地址: http://www.chilcoo.com/ccerp
# ----------------------------------------------------------------------------
# 这不是一个自由软件！你不能通过任何方式破解本软件.
# 使用:不允许对程序代码以任何形式任何目的的再发布。
# ============================================================================
# $Author: Chilcoo Inc. *
# $Official website  : www.chilcoo.com
# オーダー処理のページ
# 
# 開発日記：
# 2011－04－15
# ただいま購入用の基本データーの処理は一部完了しました。
# カートの処理と確認ビュー及びバックのAJAX処理はまだ完成していません。
*/
ajax_callback_page = '<{$ROOTPATH}>/_manager/bank/default.php';

var bank = {
	topmenu_id:'#topnav_admin',
	form:{
		_name:'#newbank_form',
		_title:'#newbank_form_title',
		bankId: '#bank_bankId_text', 
		bank: '#bank_bank_text', 
		branch: '#bank_branch_text', 
		bankno: '#bank_bankno_text', 
		name: '#bank_name_text', 
		url: '#bank_url_text',
		important:'#bank_important_text',
		id:'#bank_id_hidden',
		ok:'#newbank_form_ok',
		important_change:'#bank_important_change_hidden',
		important_passwd:'#bank_important_passwd',
		important_link:'#bank_important_link'
	},
	item:{
		bank:'#admin_bank_hidden_',
		branch:'#admin_branch_hidden_',
		bankno:'#admin_bankno_hidden_',
		name:'#admin_name_hidden_',
		url:'#admin_url_hidden_'
	},
	del:{
		_name:"#delbank_form",
		id:'#delete_bank_id'
	},
	important_form:{
		_name:"#important_form",
		passwd:"#bank_important_passwd1",
		tr_passwd:'#important_tr_passwd',
		view:"#important_view",
		id:'#bank_id_hidden1'
	},
	init:function(){
		$(this.topmenu_id).attr('class','topmenu_item_thispage');
	},
	show_passwd:function(id)
	{
		$(bank.important_form.view).hide();
		$(bank.important_form.tr_passwd).show();
		$(bank.important_form.passwd).val('');
		$(bank.important_form.view).val('');
		$(bank.important_form.id).val(id);
		blockDesign.form( $(bank.important_form._name),'550px','20%','25%');
	},
	show_important:function(){
		$.ajax({
			url:ajax_callback_page,
			data:{
				token:TOKEN_LOAD_IMPORTANT,
				bankId:$(bank.important_form.id).val(),
				important_passwd:$(bank.important_form.passwd).val()
			},
			success:function(data){
				if(data.ref == 'OK'){
					$(bank.important_form.view).show();
					$(bank.important_form.view + ' > td').html('<pre>'+data.important+'</pre>');
					$(bank.important_form.tr_passwd).hide();
				}else if(data.ref == 'NOPASS'){
					alert('パスワードが正しくありません');
					$(bank.important_form.passwd).val('');
					$(bank.important_form.passwd).focus();
				}
			},
			error:function(){
				blockDesign.defualt('<p>エラー発送しました。<p>','250px');
			},
			beforeSend:function(){
			}
		});
	},
	load_important:function(){
		var n_form = bank.form;
		$.ajax({
			url:ajax_callback_page,
			data:{
				token:TOKEN_LOAD_IMPORTANT,
				bankId:$(n_form.id).val(),
				important_passwd:$(n_form.important_passwd).val()
			},
			success:function(data){
				if(data.ref == 'OK'){
					$(bank.form.important).val(data.important);
					$(bank.form.important).show();
					$(bank.form.important_passwd).hide();
					$(bank.form.important_link).hide();
					$(bank.form.important_change).val(0);
				}else if(data.ref == 'NOPASS'){
					alert('パスワードが正しくありません');
					$(bank.form.important_passwd).val('');
					$(bank.form.important_passwd).focus();
				}
			},
			error:function(){
				blockDesign.defualt('<p>エラー発送しました。<p>','250px');
			},
			beforeSend:function(){
			}
		});
	},
	todo:function(id,_type){
		if(_type == 0){//update
			var n_form = bank.form;
			var item = bank.item;
			$(n_form._name + ' input').val('');
			$(n_form.id).val(id);
			$(n_form.bank).val($(item.bank+id).val());
			$(n_form.branch).val($(item.branch+id).val());
			$(n_form.bankno).val($(item.bankno+id).val());
			$(n_form.name).val($(item.name+id).val());
			$(n_form.url).val($(item.url+id).val());
			$(n_form.important).hide();
			$(n_form.important_change).val(-1); // not change
			$(n_form.important_passwd).show();
			$(n_form.important_link).show();
			$(n_form.ok).text('変更して保存');
			$(n_form._title).text('業者様をを編集する');
			blockDesign.form( $(bank.form._name),'550px','20%','25%');
			
		}
		<{if $login_adminId == 1}>
		else if(_type == 1){//del
			var d_form = bank.del;
			$.ajax({
				url:ajax_callback_page,
				data:{
					token:TOKEN_DEL_BANK,
					bankId:$(d_form.id).val()
				},
				success:function(data){
					if(data.ref == 'OK'){
						blockDesign.defualt('<p>削除しました。<p>','250px');
					}
				},
				error:function(){
					blockDesign.defualt('<p>エラー発送しました。<p>','250px');
				},
				beforeSend:function(){
				}
			});
		}
		<{/if}>
		else if(_type == 2){//add
			var n_form = bank.form;
			$(n_form._name + ' input').val('');
			$(n_form.id).val('0');
			$(n_form.ok).text('新規作成');
			$(n_form._title).text('業者様を新規作成する');
			$(n_form.important_passwd).hide();
			$(n_form.important_link).hide();
			$(n_form.important).show();
			$(n_form.important_change).val(0); // change
			blockDesign.form( $(bank.form._name),'550px','20%','25%');
		}
	},
	update:function(){
		var n_form = bank.form;
		if($(n_form.bank).val() == ''){
			alert('请完整填写所有信息.');
			$(n_form.bank).focus();
			return;
		}
		if($(n_form.branch).val() == ''){
			alert('请完整填写所有信息.');
			$(n_form.branch).focus();
			return;
		}
		if($(n_form.bankno).val() == ''){
			alert('请完整填写所有信息.');
			$(n_form.bankno).focus();
			return;
		}
		if($(n_form.name).val() == ''){
			alert('请完整填写所有信息.');
			$(n_form.name).focus();
			return;
		}
		ajaxClicked(this.form.ok);
		$.ajax({
			url:ajax_callback_page,
			data:{
				token:TOKEN_UP_BANK,
				bank:$(n_form.bank).val(),
				branch:$(n_form.branch).val(),
				bankno:$(n_form.bankno).val(),
				name:$(n_form.name).val(),
				url:$(n_form.url).val(),
				important:$(n_form.important).val(),
				important_change:$(n_form.important_change).val(),
				bankId:$(n_form.id).val()
			},
			success:function(data){
				if(data.ref == 'OK'){
					blockDesign.defualt('<p>更新しました。<p>','250px');
				}else{
					alert(data.ref);
				}
			},
			error:function(){
				//blockDesign.defualt('<p>エラー発送しました。<p>','250px');
			},
			beforeSend:function(){
			}
		});
	},
	add:function(){
		var n_form = bank.form;
		if($(n_form.bank).val() == ''){
			alert('请完整填写所有信息.');
			$(n_form.bank).focus();
			return;
		}
		if($(n_form.branch).val() == ''){
			alert('请完整填写所有信息.');
			$(n_form.branch).focus();
			return;
		}
		if($(n_form.bankno).val() == ''){
			alert('请完整填写所有信息.');
			$(n_form.bankno).focus();
			return;
		}
		if($(n_form.name).val() == ''){
			alert('请完整填写所有信息.');
			$(n_form.name).focus();
			return;
		}
		ajaxClicked(this.form.ok);
		$.ajax({
			url:ajax_callback_page,
			data:{
				token:TOKEN_ADD_BANK,
				bank:$(n_form.bank).val(),
				branch:$(n_form.branch).val(),
				bankno:$(n_form.bankno).val(),
				name:$(n_form.name).val(),
				url:$(n_form.url).val(),
				important:$(n_form.important).val()
			},
			success:function(data){
				if(data.ref == 'OK'){
					blockDesign.defualt('<p>新規作成しました。<p>','250px');
				}
			},
			error:function(){
				blockDesign.defualt('<p>エラー発送しました。<p>','250px');
			},
			beforeSend:function(){
			}
		});
	},
}